import http, {token} from './http.js'
import {USER_SESSION_URL, USER_LOGIN_URL, USER_LOGOUT_URL} from './url.js'

const getUserSession = (jsCode) => {
	return http({
		baseUrl: 'http://192.168.31.110:3000',
		method: 'post',
		url: USER_SESSION_URL,
		data: {
			"data": {
				"jsCode": jsCode,
				"clientCode": 1
			},
			"appId": 1005,
			"apiVersion": "5.0",
		}
	}).then(res => {
		return res
	}).catch(err => {
		console.log('getUserSession-err---', err)
	})
}

const login = (options) => {
	return http({
		baseUrl: 'http://192.168.31.110:3000',
		method: 'post',
		url: USER_LOGIN_URL,
		data: {
			"data": {
				"clientCode": 1,
				"needCheckMobile": 0,
				// "session3rd": "JeZIFjueiTxnpekUnD5yJZCau8AmhzN2YmoyV3E8UmhUit6blVlA/2KeIHMDBNXJGi+Ipuronqw=",
				// "rawData": "{\"nickName\":\"冠勋\",\"gender\":1,\"language\":\"zh_CN\",\"city\":\"Guangzhou\",\"province\":\"Guangdong\",\"country\":\"China\",\"avatarUrl\":\"https://wx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTISvtPbN7f9NsWPEic4o0uG40aZuLCp1KnibbbjPwIuyGAFAE2SUIGr7InWmKGe3G9oiaU1jpElwJW2A/132\"}",
				// "signature": "d4d61f0c61b8fb8fe9ade112f08a1d561fba28b3",
				// "encryptedData": "kbdzyKOiRTna/Mgb/ABr9SaV2xnnfimB+psZfywlDI9bUFdK3KKnrHeem92YxiJvOZVrXsJUDX7VD/LxaMDTBOE3l6/qPlrYUWpaRl858/e2BXNXHgxyAUFkGd8Z7JS1XI8nA7b/+nBoNONkJSLppWX1+LpFGlnrYB/DQvd27icTGmsbHKigvQYPSsfDmMUFInEBJoEl3SYFfqnX22kdWGZCLI+gI4RdIFwzyevnaQnaBdOmY0tqax4o4OIO1P5HlWUr3N2fRDXtcnS8aWt/tkip3lR3S0Sf6qiY0o8m9c0a5sPpN2AEDxFHtzOpeLkgRc/PDp7fjEDl76y21mswHt5pAHTaAWhgxpZnIXMTgRCUzQKkKGyAD9I3/is1WIwH82iahthePZkAwgdFwZerclAZ7o8tPSriRYgRS1PbaBiIELPIAx0dhMvZt3xNsuLJNmPlc8GXasOql8GERAbb3jdyNlP2yq2InEIgO4y7eX8M6nUDhRd8SHiF6DMORs+DkUXKTOY5htcTMx2WlIkNCQ==",
				// "iv": "4Tg6X4YSJDltq+Y8+DyPog==",
				...options
			},
			"appId": 1005,
			"apiVersion": "5.0"
		}
	}).then(res => {
		return res
	}).catch(err => {
		console.log('login-err---', err)
	})
}

const logout = (userToken, userId) => {
	return http({
		method: 'post',
		url: USER_LOGOUT_URL,
		data: {
			"appId": 1005,
			"apiVersion": "5.0",
			"isShowLoading": true,
			"userToken": token,
			"data": {
				"userId": 3644328
			}
		}
	}).then(res => {
		return res
	}).catch(err => {
		console.log('logout-err---', err)
	})
}

export {getUserSession, login, logout}